package whf.framework.log.interceptors;

import java.io.Serializable;
import java.util.Iterator;

import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor;
import org.hibernate.EntityMode;
import org.hibernate.Interceptor;
import org.hibernate.Transaction;
import org.hibernate.type.Type;

import whf.framework.log.Log;
import whf.framework.log.LogFactory;

/**
 * @author king
 * @create 2008-1-21 下午02:52:46
 * 
 */
@SuppressWarnings("unchecked")
public class HibernateAuditInterceptor extends EmptyInterceptor implements Interceptor {
	private static Log log = LogFactory.getLog(HibernateAuditInterceptor.class);

	public void afterTransactionBegin(Transaction tx) {
		log.debug("afterTransactionBegin");
		super.afterTransactionBegin(tx);
	}

	public void beforeTransactionCompletion(Transaction tx) {
		log.debug("beforeTransactionCompletion");
		super.beforeTransactionCompletion(tx);
	}

	public void afterTransactionCompletion(Transaction tx) {
		log.debug("afterTransactionCompletion");
		super.afterTransactionCompletion(tx);
	}

	public int[] findDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) {
		log.debug("findDirty");
		return super.findDirty(entity, id, currentState, previousState, propertyNames, types);
	}

	public Object getEntity(String entityName, Serializable id) throws CallbackException {
		log.debug("getEntity");
		return super.getEntity(entityName, id);
	}

	public String getEntityName(Object object) throws CallbackException {
		log.debug("getEntityName");
		return super.getEntityName(object);
	}

	public Object instantiate(String entityName, EntityMode entityMode, Serializable id) throws CallbackException {
		log.debug("instantiate");
		return super.instantiate(entityName, entityMode, id);
	}

	public Boolean isTransient(Object entity) {
		log.debug("isTransient");
		return super.isTransient(entity);
	}

	public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException {
		log.debug("isTransient");
		super.onCollectionRecreate(collection, key);
	}

	public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {
		log.debug("onCollectionRemove");
		super.onCollectionRemove(collection, key);
	}

	public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {
		log.debug("onCollectionUpdate");
		super.onCollectionUpdate(collection, key);
	}

	public void onDelete(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException {
		log.debug("onDelete");
		super.onDelete(entity, id, state, propertyNames, types);
	}

	public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) throws CallbackException {
		log.debug("onFlushDirty");
		return super.onFlushDirty(entity, id, currentState, previousState, propertyNames, types);
	}

	public boolean onLoad(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException {
		log.debug("onLoad");
		return super.onLoad(entity, id, state, propertyNames, types);
	}

	public String onPrepareStatement(String sql) {
		log.debug("onPrepareStatement:" + sql);
		return super.onPrepareStatement(sql);
	}

	public boolean onSave(Object entity, Serializable id, Object[] state, String[] propertyNames, Type[] types) throws CallbackException {
		log.debug("onSave");
		return super.onSave(entity, id, state, propertyNames, types);
	}

	public void postFlush(Iterator entities) throws CallbackException {
		log.debug("postFlush");
		super.postFlush(entities);
	}

	public void preFlush(Iterator entities) throws CallbackException {
		log.debug("preFlush");
		super.preFlush(entities);
	}

}
